<?php
/**
 * This file is part from Ewuroweb Shop
 *
 * @package 
 * @author Ivan I. Atanasov <i.atanasov@viscomp.bg>
 */

require_once('SimpleTest/unit_tester.php');
require_once('Testing/Selenium.php');

class VisSeleniumTestCase extends UnitTestCase {
    
    /**
     * List of Selenium Commands
     * 
     * @var array
     * @access private
     */
    private $_commands = array();
    
    /**
     * Selenium Command Dispatcher
     * 
     * @var Testing_Selenium
     * @access private
     */
    private $_selenium = NULL;
    
    /**
     * Default Constructor
     * 
     * @param string $label
     * @return VisSeleniumTestCase
     */
    function __construct($label = false) {
        parent::__construct($label);
        
        $this->_selenium = VisSeleniumSession::GetSelenium();
    }
    //=====================================================================================
    
    /**
     * (non-PHPdoc)
     * @see VisTesting/library/SimpleTest/SimpleTestCase#setUp()
     */
    function setUp() {
        //$this->_selenium = new Testing_Selenium("*firefox /usr/lib/firefox-3.0.15/firefox", "http://ewshop.fb");
        //$result = $this->selenium->start();    
    }
    //=====================================================================================
    
    /**
     * (non-PHPdoc)
     * @see VisTesting/library/SimpleTest/SimpleTestCase#tearDown()
     */
    function tearDown() {
       // $this->selenium->stop();
    }
    //=====================================================================================
    
    /**
     * @param map $command
     * @return void
     */
    function addCommand($command) {
        $this->_commands[] = $command;
    }
    //======================================================================================
    
    /*
     * Test Runner
     * 
     */
    function test() {
        foreach($this->_commands as $c) {
            if($c['value'] === '') {
                $this->_selenium->$c['command']($c['target']);
            }
            else {
                $this->_selenium->$c['command']($c['target'], $c['value']);
            }
        }
    }
    //=====================================================================================
    
}
